package com.djl.sqtg.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class OrderNumberUtil {
    /**
     * 获取YYYY-MM-DD HH:mm:ss:SS格式 精确到毫秒
     * @return
     */
    public static String getTime() {
        SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SS");
//        System.out.println("时间戳："+sdfTime.format(new Date()));
        return sdfTime.format(new Date()).replaceAll("[[\\s-:punct:]]", "");
    }
    /**
     * 随机生成六位数验证码
     * @return
     */
    public static int getRandomNum(){
        Random r = new Random();
        return r.nextInt(900000)+100000;//(int)(Math.random()*999999)
    }

    public static String getOrderNum(){
        return getTime()+getRandomNum();
    }
}
